import 'package:flutter_admin/models/odoo/purchase_evaluation_template.dart';
import 'package:flutter_admin/pages/common/cry/cry_all.dart';
import 'package:flutter_admin/pages/common/cry/vo/select_option_vo.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_admin/pages/common/cry/cry_button.dart';
import '../../../generated/l10n.dart';

class PurchaseEvaluationTemplateDialog extends StatefulWidget {
  PurchaseEvaluationTemplateDialog();

  @override
  _PurchaseEvaluationTemplateDialogState createState() =>
      _PurchaseEvaluationTemplateDialogState();
}

class _PurchaseEvaluationTemplateDialogState
    extends State<PurchaseEvaluationTemplateDialog> {
  // late List<Widget> children;
  final GlobalKey<FormState> formKey = GlobalKey<FormState>();

  PurchaseEvaluationTemplate purchaseEvaluationTemplate =
      PurchaseEvaluationTemplate();
  List<SelectOptionVO> customerNatureList = [];

  @override
  void initState() {
    super.initState();
    _loadData();
  }

  _loadData() async {
    setState(() {});
  }

  @override
  Widget build(BuildContext context) {
    var form = Form(
      key: formKey,
      child: Wrap(
        children: <Widget>[
          CryInput(
            width: 280,
            label: '模板名称',
            value: purchaseEvaluationTemplate.templateName,
            onSaved: (v) {
              purchaseEvaluationTemplate.templateName = v;
            },
          ),
        ],
      ),
    );
    var buttonBar = ButtonBar(
      alignment: MainAxisAlignment.center,
      children: <Widget>[
        CryButton(
          label: "确定",
          onPressed: () {
            FormState form = formKey.currentState!;
            form.save();
            Navigator.pop(context, purchaseEvaluationTemplate);
          },
          iconData: Icons.save,
        ),
        CryButton(
          label: S.of(context).cancel,
          onPressed: () {
            Navigator.pop(context);
          },
          iconData: Icons.cancel,
        )
      ],
    );
    var result = Scaffold(
      appBar: AppBar(
        title: Text("查询"),
      ),
      body: SingleChildScrollView(
        child: Column(
          children: [form],
        ),
      ),
      bottomNavigationBar: buttonBar,
    );
    return SizedBox(
      width: 650,
      height: 650,
      child: result,
    );
    // return result;
  }
}
